package com.android.hedgehog;

import java.util.List;

import android.R.color;
import android.graphics.Color;

import com.android.hedgehog.framework.Game;
import com.android.hedgehog.framework.Graphics;
import com.android.hedgehog.framework.Input.TouchEvent;
import com.android.hedgehog.framework.Screen;
import com.android.hedgehog.Settings;

public class MainMenu extends Screen {
	public MainMenu(Game game) {
		super(game);
	}

	@Override
	public void update(float deltaTime) {
		Graphics g = game.getGraphics();
		List<TouchEvent> touchEvents = game.getInput().getTouchEvents();

		int len = touchEvents.size();

		for (int i = 0; i < len; i++) {
			TouchEvent event = touchEvents.get(i);
			if (event.type == TouchEvent.TOUCH_UP && event.x > 95
					&& event.x < 215) { // if any of the 5 buttons were touched

				if(true){
					//game.profileScreen();
				}
				
				if (event.y > 240 && event.y < 280) { // if "Story Mode" touched
					 game.setScreen(new LevelSelect(game));
					if (Settings.soundEnabled)
						Assets.bitten.play(1);
					return;
				}
				if (event.y > 280 && event.y < 320) { // if "FreePlay" touched
					game.setScreen(new FreePlayMenu(game));
					if (Settings.soundEnabled)
						Assets.bitten.play(1);
					return;
				}
				if (event.y > 320 && event.y < 360) { // if "Records" touched
					game.setScreen(new Records(game));
					if (Settings.soundEnabled)
						Assets.bitten.play(1);
					return;
				}
				if (event.y > 360 && event.y < 400) { // if "Bonus" touched
					// game.setScreen(new Bonus(game));
					if (Settings.soundEnabled)
						Assets.bitten.play(1);
					return;
				}
				if (event.y > 400 && event.y < 440) { // if "credits" touched
					// game.setScreen(new Credits(game));
					if (Settings.soundEnabled)
						Assets.bitten.play(1);
					return;
				}

			}
			if (event.type == TouchEvent.TOUCH_UP && event.x < 50
					&& event.y > 430) { // if sound option touched
				Settings.soundEnabled = !Settings.soundEnabled;
				//Settings.globalRank=0;
				Settings.userName="Tommy";
				Settings.age=5;
				Assets.click.play(1);
			}
		}
	}

	@Override
	public void present(float deltaTime) {
		Graphics g = game.getGraphics();
		g.drawPixmap(Assets.mainmenu, 0, 0);
		if (Settings.soundEnabled)
			g.drawPixmap(Assets.soundbuttons, 0, 430, 0, 0, 50, 50);
		else
			g.drawPixmap(Assets.soundbuttons, 0, 430, 50, 0, 50, 50);
	}

	@Override
	public void pause() {
		Settings.save(game.getFileIO());
		
	}

	@Override
	public void resume() {

	}

	@Override
	public void dispose() {

	}
}
